package com.huhu.levelloader;

import java.util.ArrayList;

import org.andengine.engine.Engine;
import org.andengine.engine.camera.BoundCamera;
import org.andengine.engine.camera.hud.HUD;
import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.PathModifier;
import org.andengine.entity.modifier.PathModifier.IPathModifierListener;
import org.andengine.entity.modifier.PathModifier.Path;
import org.andengine.entity.primitive.Rectangle;
import org.andengine.entity.sprite.Sprite;
import org.andengine.extension.physics.box2d.PhysicsConnector;
import org.andengine.extension.physics.box2d.PhysicsFactory;
import org.andengine.extension.physics.box2d.PhysicsWorld;
import org.andengine.extension.tmx.TMXObject;
import org.andengine.extension.tmx.TMXObjectGroup;
import org.andengine.extension.tmx.TMXTiledMap;
import org.andengine.input.touch.TouchEvent;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.modifier.ease.EaseSineInOut;

import android.util.Log;

import com.badlogic.gdx.physics.box2d.Body;
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType;
import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Fixture;
import com.badlogic.gdx.physics.box2d.FixtureDef;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.huhu.manager.ResourcesManager;
import com.huhu.manager.SceneManager;
import com.huhu.objects.Player;
import com.huhu.scenes.GameScene;

public class LevelLoader1_2 extends LevelLoader{
	private HUD gameHUD;
	private final FixtureDef FIXTURE_DEF = PhysicsFactory.createFixtureDef(0,
			0.01f, 0.5f);

	private Player player;
	private boolean gameOverDisplayed = false;
	private boolean levelCompleteDisplayed = false;

	private Sprite trapSprite;
	private Body trapBody;
	private Sprite switchMachineSprite;

	private Sprite box1Sprite;
	private Body box1Body;

	private Sprite box3Sprite;
	private Body box3Body;

	private Sprite box4Sprite;
	private Body box4Body;

	private Sprite box6Sprite;
	private Body box6Body;

	private Sprite box7Sprite;
	private Body box7Body;

	private Sprite springSprite;

	private Sprite boxLeftSprite;
	private Body boxLeftBody;
	private Sprite boxRightSprite;
	private Body boxRightBody;
	private boolean collidesedWithRec1 = false;

	private Sprite flowerSprite;

	public LevelLoader1_2(Engine engine, GameScene scene, BoundCamera camera,
			PhysicsWorld physicsWorld, VertexBufferObjectManager vbom) {
		super(engine, scene, camera, physicsWorld, vbom);
	}
	

	@Override
	protected void createHUD() {
		gameHUD = new HUD();

		final Sprite spriteMoveLeft = new Sprite(10, 520,
				resourcesManager.move_left_region, vbom) {
			@Override
			public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
					float pTouchAreaLocalX, float pTouchAreaLocalY) {
				if (pSceneTouchEvent.isActionDown()) {
					player.setDirection(false);
					player.setRunning();
				} else {
					player.setStopping();
				}
				return true;
			}
		};
		gameHUD.registerTouchArea(spriteMoveLeft);
		gameHUD.attachChild(spriteMoveLeft);

		final Sprite spriteMoveRight = new Sprite(135, 520,
				resourcesManager.move_right_region, vbom) {
			@Override
			public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
					float pTouchAreaLocalX, float pTouchAreaLocalY) {
				if (pSceneTouchEvent.isActionDown()) {
					player.setDirection(true);
					player.setRunning();
				} else {
					player.setStopping();
				}
				return true;
			}
		};
		gameHUD.registerTouchArea(spriteMoveRight);
		gameHUD.attachChild(spriteMoveRight);

		final Sprite spriteJump = new Sprite(876, 520,
				resourcesManager.jump_region, vbom) {
			@Override
			public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
					float pTouchAreaLocalX, float pTouchAreaLocalY) {
				if(pSceneTouchEvent.isActionDown()){
					player.jump();
				}

				return true;
			}
		};
		gameHUD.registerTouchArea(spriteJump);
		gameHUD.attachChild(spriteJump);

		final Sprite spriteBack = new Sprite(10, 10,
				resourcesManager.back_region, vbom) {
			@Override
			public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
					float pTouchAreaLocalX, float pTouchAreaLocalY) {
				SceneManager.getInstance().getCurrentScene().onBackKeyPressed();
				return true;
			}
		};
		gameHUD.registerTouchArea(spriteBack);
		gameHUD.attachChild(spriteBack);

		camera.setHUD(gameHUD);
		
	}

	public Player createPlatform(TMXTiledMap mTMXTiledMap) {
		final ArrayList<TMXObjectGroup> mTMXObjectGroups = mTMXTiledMap
				.getTMXObjectGroups();
		for (TMXObjectGroup mTMXObjectGroup : mTMXObjectGroups) {
			final FixtureDef FIXTURE_DEF = PhysicsFactory.createFixtureDef(
					0.0f, 0.01f, 0.5f);
			if (mTMXObjectGroup.getTMXObjectGroupProperties()
					.containsTMXProperty("platformobject", "true")) {
				for (TMXObject mTMXObject : mTMXObjectGroup.getTMXObjects()) {
					Rectangle rectangle = new Rectangle(mTMXObject.getX(),
							mTMXObject.getY(), mTMXObject.getWidth(),
							mTMXObject.getHeight(), vbom);
					Body body_platform = PhysicsFactory.createBoxBody(
							physicsWorld, rectangle, BodyType.StaticBody,
							FIXTURE_DEF);
					body_platform.setUserData("body_platform_data");
					rectangle.setVisible(false);
					this.scene.attachChild(rectangle);
				}
			} else if (mTMXObjectGroup.getTMXObjectGroupProperties()
					.containsTMXProperty("object", "true")) {
				for (TMXObject mTMXObject : mTMXObjectGroup.getTMXObjects()) {
					final float x = mTMXObject.getX();
					final float y = mTMXObject.getY();
					final float width = mTMXObject.getWidth();
					final float height = mTMXObject.getHeight();
					if (mTMXObject.getName() == null) {
						Log.d("mTMXObject", "null name");
						continue;
					}
					if (mTMXObject.getName().equals("switchmachine")) {
						resourcesManager.loadSwitchMachineGraphics();
						switchMachineSprite = new Sprite(x, y,
								resourcesManager.switch_machine_region, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player)) {
									if (player.getX() > switchMachineSprite
											.getX()
											+ switchMachineSprite.getWidth()
											/ 2) {
										if (trapBody.getType() == BodyType.StaticBody) {
											resourcesManager
													.replaceSwitchMachineTexture();
											trapBody.setType(BodyType.DynamicBody);
										}
									}
								}
							}
						};
						scene.attachChild(switchMachineSprite);
					}

					if (mTMXObject.getName().equals("trap")) {
						trapSprite = new Sprite(x, y,
								resourcesManager.trap_region, vbom);
						trapBody = PhysicsFactory.createBoxBody(physicsWorld,
								trapSprite, BodyType.StaticBody, FIXTURE_DEF);
						trapBody.setUserData("trap_body_data");
						scene.attachChild(trapSprite);
						physicsWorld
								.registerPhysicsConnector(new PhysicsConnector(
										trapSprite, trapBody, true, false));
					}

					if (mTMXObject.getName().equals("box1")) {
						box1Sprite = new Sprite(x, y,
								resourcesManager.unknow_brickover_region, vbom);
						box1Body = PhysicsFactory.createBoxBody(physicsWorld,
								box1Sprite, BodyType.StaticBody, FIXTURE_DEF);
						box1Body.setUserData("box1_body_data");
						box1Body.setActive(false);
						box1Sprite.setVisible(false);
						scene.attachChild(box1Sprite);
					}

					if (mTMXObject.getName().equals("box2")) {
						final Rectangle recBox2 = new Rectangle(x, y, width,
								height, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player)) {
									if (!box1Body.isActive()) {
										box1Body.setActive(true);
									}
								} else {
									if (!box1Sprite.isVisible()) {
										box1Body.setActive(false);
									}
								}
							}
						};
						recBox2.setVisible(false);
						scene.attachChild(recBox2);
					}
					if (mTMXObject.getName().equals("box3")) {
						box3Sprite = new Sprite(x, y,
								resourcesManager.unknow_brickover_region, vbom);
						box3Body = PhysicsFactory.createBoxBody(physicsWorld,
								box3Sprite, BodyType.StaticBody, FIXTURE_DEF);
						box3Body.setUserData("box3_body_data");
						box3Body.setActive(false);
						box3Sprite.setVisible(false);
						scene.attachChild(box3Sprite);
					}
					if (mTMXObject.getName().equals("box4")) {
						box4Sprite = new Sprite(x, y,
								resourcesManager.unknow_brickover_region, vbom);
						box4Body = PhysicsFactory.createBoxBody(physicsWorld,
								box4Sprite, BodyType.StaticBody, FIXTURE_DEF);
						box4Body.setUserData("box4_body_data");
						box4Body.setActive(false);
						box4Sprite.setVisible(false);
						scene.attachChild(box4Sprite);
					}
					if (mTMXObject.getName().equals("box5")) {
						final Rectangle recBox5 = new Rectangle(x, y, width,
								height, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player)) {
									if (!box6Body.isActive()) {
										box6Body.setActive(true);
									}
								} else {
									if (!box6Sprite.isVisible()) {
										box6Body.setActive(false);
									}
								}
							}
						};
						recBox5.setVisible(false);
						scene.attachChild(recBox5);
					}
					if (mTMXObject.getName().equals("box6")) {
						box6Sprite = new Sprite(x, y,
								resourcesManager.unknow_brickover_region, vbom);
						box6Body = PhysicsFactory.createBoxBody(physicsWorld,
								box6Sprite, BodyType.StaticBody, FIXTURE_DEF);
						box6Body.setUserData("box6_body_data");
						box6Body.setActive(false);
						box6Sprite.setVisible(false);
						scene.attachChild(box6Sprite);
					}
					if (mTMXObject.getName().equals("box7")) {
						box7Sprite = new Sprite(x, y,
								resourcesManager.unknow_brickover_region, vbom);
						box7Body = PhysicsFactory.createBoxBody(physicsWorld,
								box7Sprite, BodyType.StaticBody, FIXTURE_DEF);
						box7Body.setUserData("box7_body_data");
						box7Body.setActive(false);
						box7Sprite.setVisible(false);
						scene.attachChild(box7Sprite);
					}
					if (mTMXObject.getName().equals("box8")) {
						final Rectangle recBox8 = new Rectangle(x, y, width,
								height, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player)) {
									if (!box4Body.isActive()) {
										box4Body.setActive(true);
									}
								} else {
									if (!box4Sprite.isVisible()) {
										box4Body.setActive(false);
									}
								}
							}
						};
						recBox8.setVisible(false);
						scene.attachChild(recBox8);
					}
					if (mTMXObject.getName().equals("flower")) {
						flowerSprite = new Sprite(x, y,
								resourcesManager.flower_region, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player) && isVisible()) {
									player.setDie(true);
								}
							}
						};
						flowerSprite.setVisible(false);
						scene.attachChild(flowerSprite);
					}
					if (mTMXObject.getName().equals("showflower")) {
						final Rectangle recFlower = new Rectangle(x, y, width,
								height, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player)
										&& !flowerSprite.isVisible()) {
									if (player.getY() >= y - 5) {
										flowerSprite.setVisible(true);
									}
								}
							}
						};
						recFlower.setVisible(false);
						scene.attachChild(recFlower);
					}
					if (mTMXObject.getName().equals("glass")) {
						final Rectangle recGlass = new Rectangle(x, y, width,
								height, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player) && !player.isDie()) {
									int count = (int) (width / 96);
									Log.d("Glass", count + "");
									for (int i = 0; i < count; i++) {
										final Sprite sawSprite = new Sprite(
												x + 96 * i,
												y + height / 2,
												resourcesManager.saw_top_red_region,
												vbom);
										scene.attachChild(sawSprite);
									}
									player.setDie(true);
								}
							}
						};
						recGlass.setVisible(false);
						scene.attachChild(recGlass);
					}
					// if (mTMXObject.getName().equals("cloud")) {
					// resourcesManager.loadCloudGraphics();
					// final Sprite cloudSprite = new Sprite(x, y,
					// resourcesManager.cloud_normal_region, vbom) {
					// @Override
					// protected void onManagedUpdate(float pSecondsElapsed) {
					// // TODO Auto-generated method stub
					// super.onManagedUpdate(pSecondsElapsed);
					// if (collidesWith(player) && !player.isDie()) {
					// resourcesManager.replaceCloudTexture();
					// player.setDie(true);
					// }
					// }
					// };
					// scene.attachChild(cloudSprite);
					// }
					if (mTMXObject.getName().equals("save")) {
						SceneManager.savePositionX = x;
						SceneManager.savePositionY = y;
						final Sprite saveSprite = new Sprite(x, y,
								resourcesManager.save_flat_region, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player)) {
									SceneManager.saveActivte = true;
									setVisible(false);
								}
							}
						};
						scene.attachChild(saveSprite);
					}
					if (mTMXObject.getName().equals("spring")) {
						springSprite = new Sprite(x, y,
								resourcesManager.spring_region, vbom);
						final Body springBody = PhysicsFactory.createBoxBody(
								physicsWorld, springSprite,
								BodyType.StaticBody, FIXTURE_DEF);
						springBody.setUserData("spring_body_data");
						scene.attachChild(springSprite);
					}
					if (mTMXObject.getName().equals("boxleft")) {
						boxLeftSprite = new Sprite(x, y,
								resourcesManager.unknown_region, vbom);
						scene.attachChild(boxLeftSprite);
//						physicsWorld.registerPhysicsConnector(new PhysicsConnector(boxLeftSprite, boxLeftBody, true, false));
					}
					if (mTMXObject.getName().equals("boxright")) {
						boxRightSprite = new Sprite(x, y,
								resourcesManager.unknown_region, vbom);

						scene.attachChild(boxRightSprite);
//						physicsWorld.registerPhysicsConnector(new PhysicsConnector(boxRightSprite, boxRightBody, true, false));
					}
					if (mTMXObject.getName().equals("rec1")) {
						final Rectangle rec1 = new Rectangle(x, y, width,
								height, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player)) {
									if (!collidesedWithRec1) {
										Path path1 = new Path(2).to(
												boxLeftSprite.getX(),
												boxLeftSprite.getY()).to(
												boxLeftSprite.getX() - 64,
												boxLeftSprite.getY());
										boxLeftSprite
												.registerEntityModifier(new PathModifier(
														0.1f,
														path1,
														new IPathModifierListener() {

															@Override
															public void onPathWaypointStarted(
																	PathModifier pPathModifier,
																	IEntity pEntity,
																	int pWaypointIndex) {
																// TODO
																// Auto-generated
																// method stub

															}

															@Override
															public void onPathWaypointFinished(
																	PathModifier pPathModifier,
																	IEntity pEntity,
																	int pWaypointIndex) {
																// TODO
																// Auto-generated
																// method stub

															}

															@Override
															public void onPathStarted(
																	PathModifier pPathModifier,
																	IEntity pEntity) {
																// TODO
																// Auto-generated
																// method stub

															}

															@Override
															public void onPathFinished(
																	PathModifier pPathModifier,
																	IEntity pEntity) {
																// TODO
																// Auto-generated
																// method stub

															}
														}, EaseSineInOut
																.getInstance()));

										Path path2 = new Path(2).to(
												boxRightSprite.getX(),
												boxRightSprite.getY()).to(
												boxRightSprite.getX() + 64,
												boxRightSprite.getY());
										boxRightSprite
												.registerEntityModifier(new PathModifier(
														0.1f,
														path2,
														new IPathModifierListener() {

															@Override
															public void onPathWaypointStarted(
																	PathModifier pPathModifier,
																	IEntity pEntity,
																	int pWaypointIndex) {
																// TODO
																// Auto-generated
																// method stub

															}

															@Override
															public void onPathWaypointFinished(
																	PathModifier pPathModifier,
																	IEntity pEntity,
																	int pWaypointIndex) {
																// TODO
																// Auto-generated
																// method stub

															}

															@Override
															public void onPathStarted(
																	PathModifier pPathModifier,
																	IEntity pEntity) {
																// TODO
																// Auto-generated
																// method stub

															}

															@Override
															public void onPathFinished(
																	PathModifier pPathModifier,
																	IEntity pEntity) {
																boxLeftBody = PhysicsFactory.createBoxBody(
																		physicsWorld, boxLeftSprite,
																		BodyType.StaticBody, FIXTURE_DEF);
																boxLeftBody.setUserData("box_left_body_data");
																boxRightBody = PhysicsFactory.createBoxBody(
																		physicsWorld, boxRightSprite,
																		BodyType.StaticBody, FIXTURE_DEF);
																boxRightBody.setUserData("box_left_body_data");

															}
														}, EaseSineInOut
																.getInstance()));
									}
									collidesedWithRec1 = true;
								}
							}
						};
						rec1.setVisible(false);
						scene.attachChild(rec1);
					}
					if (mTMXObject.getName().equals("rec2")) {
						final Rectangle rec2 = new Rectangle(x, y, width,
								height, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player)) {
									if (!box7Body.isActive()) {
										box7Body.setActive(true);
									}
								} else {
									if (!box7Sprite.isVisible()) {
										box7Body.setActive(false);
									}
								}
							}
						};
						rec2.setVisible(false);
						scene.attachChild(rec2);
					}
					// if (mTMXObject.getName().equals("sawwall")) {
					// final Sprite sawSprite = new Sprite(x, y,
					// resourcesManager.saw_bottom_region, vbom) {
					// @Override
					// protected void onManagedUpdate(float pSecondsElapsed) {
					// // TODO Auto-generated method stub
					// super.onManagedUpdate(pSecondsElapsed);
					// if (collidesWith(player)) {
					// if (!isVisible()) {
					// setVisible(true);
					// player.setDie(true);
					// }
					// }
					// }
					// };
					// sawSprite.setVisible(false);
					// scene.attachChild(sawSprite);
					// }
					if (mTMXObject.getName().equals("lady")) {
						resourcesManager.loadLadyGraphics();
						final Sprite ladySprite = new Sprite(x, y,
								resourcesManager.lady_region, vbom) {
							@Override
							protected void onManagedUpdate(float pSecondsElapsed) {
								// TODO Auto-generated method stub
								super.onManagedUpdate(pSecondsElapsed);
								if (collidesWith(player)) {

									if (player.getX() <= x + width / 2) {
										resourcesManager.replaceLadyTexture();
										player.setDie(true);
									} else {
										if (!levelCompleteDisplayed) {
											levelCompleteDisplayed = true;
											scene.displayLevelComplete(SceneManager.currentLevel);
										}
									}
								}
							}
						};
						scene.attachChild(ladySprite);
					}
					if (mTMXObject.getName().equals("player")) {
						if (!SceneManager.saveActivte) {
							SceneManager.savePositionX = mTMXObject.getX();
							SceneManager.savePositionY = mTMXObject.getY();
						}
						player = new Player(SceneManager.savePositionX,
								SceneManager.savePositionY, vbom, camera,
								physicsWorld) {

							@Override
							public void onDie() {
								if (!gameOverDisplayed) {
									gameOverDisplayed = true;
									if (!ResourcesManager.getInstance().die_sound
											.isPlaying()) {
										ResourcesManager.getInstance().die_sound
												.play();
									}
									scene.displayGamOver();
								}

							}
						};

						scene.attachChild(player);
					}
				}
			}
		}
		return player;
	}

	protected ContactListener contactListener() {
		ContactListener contactListener = new ContactListener() {

			@Override
			public void preSolve(Contact contact, Manifold oldManifold) {
				// TODO Auto-generated method stub

			}

			@Override
			public void postSolve(Contact contact, ContactImpulse impulse) {
				// TODO Auto-generated method stub

			}

			@Override
			public void endContact(Contact contact) {
				final Fixture x1 = contact.getFixtureA();
				final Fixture x2 = contact.getFixtureB();
				if (x1.getBody().getUserData() != null
						&& x2.getBody().getUserData() != null) {
					Object x1_bodyData = x1.getBody().getUserData();
					Object x2_bodyData = x2.getBody().getUserData();
					if (x1_bodyData.equals("player")
							|| x2_bodyData.equals("player")) {
						player.decreaseFootContacts();
					}
				}

			}

			@Override
			public void beginContact(Contact contact) {
				final Fixture x1 = contact.getFixtureA();
				final Fixture x2 = contact.getFixtureB();
				if (x1.getBody().getUserData() != null
						&& x2.getBody().getUserData() != null) {
					Object x1_bodyData = x1.getBody().getUserData();
					Object x2_bodyData = x2.getBody().getUserData();
					Log.d("Contact", x1_bodyData + " " + x2_bodyData);
					if (x1_bodyData.equals("player")
							|| x2_bodyData.equals("player")) {
						player.increaseFootContacts();
						if (x1_bodyData.equals("trap_body_data")
								|| x2_bodyData.equals("trap_body_data")) {
							if (player.getY() >= trapSprite.getY()
									+ trapSprite.getHeight() - 10) {
								player.setDie(true);
							}
						}
						if (x1_bodyData.equals("box1_body_data")
								|| x2_bodyData.equals("box1_body_data")) {
							if (box1Body.isActive() && !box1Sprite.isVisible()) {
								box1Sprite.setVisible(true);
							}
						}
						if (x1_bodyData.equals("box4_body_data")
								|| (x2_bodyData.equals("box4_body_data"))) {
							if (box4Body.isActive() && !box4Sprite.isVisible()) {
								box4Sprite.setVisible(true);
							}
						}
						if (x1_bodyData.equals("box6_body_data")
								|| x2_bodyData.equals("box6_body_data")) {
							if (box6Body.isActive() && !box6Sprite.isVisible()) {
								box6Sprite.setVisible(true);
							}
						}
						if (x1_bodyData.equals("spring_body_data")
								|| x2_bodyData.equals("spring_body_data")) {
							if (player.getY() + player.getHeight() <= springSprite
									.getY()) {
								player.jumpHigh();
							}
						}
						if(x1.equals("box7_body_data") || x2_bodyData.equals("box7_body_data")){
							if(box7Body.isActive() && !box7Sprite.isVisible()){
								box7Sprite.setVisible(true);
							}
						}
					} else if ((x1_bodyData.equals("body_platform_data") && x2_bodyData
							.equals("trap_body_data"))
							|| (x2_bodyData.equals("body_platform_data") && x1_bodyData
									.equals("trap_body_data"))) {
						if (trapBody.getType() == BodyType.DynamicBody) {
							trapBody.setType(BodyType.StaticBody);
						}
					}
				}

			}
		};
		return contactListener;
	}
}
